require('./preload/common')

globalThis.BrowserWindow = globalThis.electron.remote.BrowserWindow

var listSelectors = require('list-selectors')
globalThis.getCssAllClassesSelectors = function(url = 'http://127.0.0.1:7001/public/css/base.css') {
  return new Promise(resolve => {
    listSelectors(url, {}, function(myList) { // callback
      resolve(myList.simpleSelectors.classes ? myList.simpleSelectors.classes : [])
    })
  })
}

var uncss = require('uncss');
var  options = {
  stylesheets  : ['http://127.0.0.1:7001/public/css/base.css'],  
}
var rawHtml = `
<div><div>
`;
globalThis.getHtmlUsedCssClass = function(html = rawHtml,) {
  return new Promise(resolve => {
    uncss(html, options, function (error, output) {
      if (error) {
        console.log(error)
      }
      resolve(output)
    });
  })
}